1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942 |
- function varargout = DriverGUI(varargin)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Configures PLS settings & calls analysis sections to run. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 2013-2014, Michael J. Cheung
- %
- % This file is a part of the MEG & PLS Pipeline (MEGPLS). For more
- % details, see the documentation included with the software package.
- %
- % MEGPLS is free software: you can redistribute it and/or modify it under
- % the terms of the GNU General Public License version 2 as published by
- % the Free Software Foundation. This program is distributed in the hope
- % that it will be useful, but WITHOUT ANY WARRANTY; without even the
- % implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- % See the GNU General Public License for more details.
- %
- % You should have received a copy of the GNU General Public License along
- % with this program. If not, you can download the license here:
- % <http://www.gnu.org/licenses/old-licenses/gpl-2.0>.
- % Last Modified by GUIDE v2.5 24-Sep-2014 01:06:42
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @DriverGUI_OpeningFcn, ...
- 'gui_OutputFcn', @DriverGUI_OutputFcn, ...
- 'gui_LayoutFcn', [] , ...
- 'gui_Callback', []);
- if nargin && ischar(varargin{1})
- gui_State.gui_Callback = str2func(varargin{1});
- end
- if nargout
- [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
- else
- gui_mainfcn(gui_State, varargin{:});
- end
- % End initialization code - DO NOT EDIT
- %--- Executes just before DriverGUI is made visible. ---%
- %-------------------------------------------------------%
- function DriverGUI_OpeningFcn(hObject, eventdata, handles, varargin)
- % This function has no output args, see OutputFcn.
- % hObject handle to figure
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % varargin command line arguments to DriverGUI (see VARARGIN)
- % Choose default command line output for DriverGUI
- handles.output = hObject;
- % Make sure toolbox paths are added:
- [PipelineDir, ~, ~] = fileparts(which('DriverGUI.m'));
- addpath(genpath(PipelineDir));
- rmpath([PipelineDir,'/DEFAULT_SETTINGS']); % Make sure its calling from AnalysisID
- rmpath([PipelineDir,'/TEMPORARY_FIXES']); % Make sure its calling from FT toolbox
- CheckToolboxPaths(PipelineDir);
- % Initialize variables and default settings:
- handles.gui.BuilderMat = [];
- handles.gui.ManualTimeIndices = [];
- handles.gui.DefaultBrainMask = ...
- [PipelineDir,'/MEGPLS_TOOLBOX/Masks_Templates/mask_T1+tlrc.BRIK'];
- handles.gui.DefaultROIMask = ...
- [PipelineDir,'/MEGPLS_TOOLBOX/Masks_Templates/area_coords_RAI.xls'];
- handles.name = [];
- handles.time = [];
- handles.paths = [];
- handles.PLSmat.OrigBuilder = [];
- handles.PLSmat.SessionID = [];
- handles.PLSmat.name.GroupID = [];
- handles.PLSmat.name.SubjID = [];
- handles.PLSmat.name.CondID = [];
- handles.PLSmat.paths.Afni4D = []; % For PLS datamat input
- handles.PLSmat.paths.NormSource = []; % For data-specific mask generation
- handles.PLSmat.paths.AnalysisID = [];
- handles.PLSmat.time = [];
- handles.PLSmat.TimeIndices = []; % Default is epoch, but no builder loaded yet
- handles.PLSmat.ManualTimeSelect = 'no';
- handles.PLSmat.MaskType = 'BrainMask';
- handles.PLSmat.DataSpecificMask = 'yes';
- handles.PLSmat.MaskKeepVoxThresh = 0.90; % 90% datasets need to share voxel for it to be included into mask.
- handles.PLSmat.BrainMaskFile = handles.gui.DefaultBrainMask;
- handles.PLSmat.ROIMaskFile = handles.gui.DefaultROIMask;
- handles.PLSmat.ROIBlobSize = [-1:1];
- handles.PLSmat.BhvSeedID = [];
- handles.PLSmat.BhvFile = [];
- handles.PLSmat.SeedFile = [];
- handles.PLSmat.SeedBlobSize = [];
- handles.PLSrun.NRContrast = [];
- handles.PLSrun.NRContrastID = [];
- handles.PLSrun.Method = 'MCENT';
- handles.PLSrun.SplitHalf = 'no';
- handles.PLSrun.SingleBhv = 'no';
- handles.PLSrun.KeepDatamat = 'no';
- handles.PLSrun.NumPerm = 500;
- handles.PLSrun.NumBoot = 500;
- handles.PLSrun.NumSplit = 0;
- handles.PLSrun.CorrMode = 0;
- handles.PLSrun.PermType = 0; % is_struct field
- handles.PLSrun.MCentType = 0;
- handles.PLSrun.BootType = 'strat';
- % Update handles structure
- guidata(hObject, handles);
- % UIWAIT makes DriverGUI wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- %--- Outputs from this function are returned to the command line. ---%
- %--------------------------------------------------------------------%
- function varargout = DriverGUI_OutputFcn(hObject, eventdata, handles)
- % varargout cell array for returning output args (see VARARGOUT);
- % hObject handle to figure
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Get default command line output from handles structure
- varargout{1} = handles.output;
- %=====================================%
- % FUNCTIONS FOR LOADING BUILDER .MAT: %
- %=====================================%
- %--- Executes on button press in ButtonLoadBuilderMat. ---%
- %---------------------------------------------------------%
- function ButtonLoadBuilderMat_Callback(hObject, eventdata, handles)
- [BuilderFile, BuilderPath] = uigetfile('Builder_*.mat',...
- 'Select Builder .mat file to load:', 'MultiSelect', 'off');
- if BuilderFile == 0
- return; % If user cancels
- else
- handles.gui.BuilderMat = [BuilderPath,BuilderFile];
- set(handles.TextboxBuilderMat, 'String', handles.gui.BuilderMat);
- end
- % Start Waitbox:
- WaitBox = StartWaitBox('LOADING BUILDER .MAT FILE:');
- % Load selected builder (for GUI purposes):
- LoadBuilder = load(handles.gui.BuilderMat);
- handles.name = LoadBuilder.name;
- handles.time = LoadBuilder.time;
- handles.paths = LoadBuilder.paths;
- % Reset PLS settings & GUI panels:
- handles = ResetPLSmatInputData (handles);
- handles = ResetTimeSettings (handles);
- handles = ResetMaskSettings (handles);
- handles = ResetBehaviorSettings (handles);
- handles = ResetPLSrunSettings (handles);
- % Load builder settings into PLSmat (for MakePLSmat & PLSrun input):
- handles.PLSmat.OrigBuilder = LoadBuilder;
- handles.PLSmat.name = LoadBuilder.name;
- handles.PLSmat.time = LoadBuilder.time;
- handles.PLSmat.paths.Afni4D = LoadBuilder.paths.Afni4DNormSource;
- handles.PLSmat.paths.NormSource = LoadBuilder.paths.NormSource;
- handles.PLSmat.paths.AnalysisID = LoadBuilder.paths.AnalysisID;
- % Reset run section values:
- set(handles.CheckboxTimelockAnalysis, 'Value', 0);
- set(handles.CheckboxTimelockGrpAvg, 'Value', 0);
- set(handles.CheckboxFreqAnalysis, 'Value', 0);
- set(handles.CheckboxFreqGrpAvg, 'Value', 0);
- set(handles.CheckboxSegmentMRI, 'Value', 0);
- set(handles.CheckboxHdmLeadfield, 'Value', 0);
- set(handles.CheckboxSourceFilter, 'Value', 0);
- set(handles.CheckboxSourceAnalysis, 'Value', 0);
- set(handles.CheckboxMakeSourceNifti, 'Value', 0);
- set(handles.CheckboxMakeSourceAfni, 'Value', 0);
- set(handles.CheckboxNormaliseSource, 'Value', 0);
- set(handles.CheckboxMakeNormSrcNifti, 'Value', 0);
- set(handles.CheckboxMakeNormSrcAfni, 'Value', 0);
- set(handles.CheckboxGroupAvgNormSrc, 'Value', 0);
- set(handles.CheckboxMakeGrpAvgNifti, 'Value', 0);
- set(handles.CheckboxMakeGrpAvgAfni, 'Value', 0);
- set(handles.CheckboxMakePLSmat, 'Value', 0);
- set(handles.CheckboxRunPLS, 'Value', 0);
- % Enable/disable run section panel:
- set(findall(handles.PanelRunTimelockFreq, '-property', 'Enable'), 'Enable', 'on');
- set(findall(handles.PanelRunSource, '-property', 'Enable'), 'Enable', 'on');
- set(findall(handles.PanelRunPLS, '-property', 'Enable'), 'Enable', 'on');
- if ~strcmp(LoadBuilder.gui.MEGdataFiletype, 'Fieldtrip')
- set(handles.CheckboxTimelockAnalysis, 'Enable', 'off');
- set(handles.CheckboxTimelockGrpAvg, 'Enable', 'off');
- set(handles.CheckboxFreqAnalysis, 'Enable', 'off');
- set(handles.CheckboxFreqGrpAvg, 'Enable', 'off');
- set(handles.CheckboxSegmentMRI, 'Enable', 'off');
- set(handles.CheckboxHdmLeadfield, 'Enable', 'off');
- set(handles.CheckboxSourceFilter, 'Enable', 'off');
- set(handles.CheckboxSourceAnalysis, 'Enable', 'off');
- set(handles.CheckboxMakeSourceNifti, 'Enable', 'off');
- set(handles.CheckboxNormaliseSource, 'Enable', 'off');
- set(handles.CheckboxMakeNormSrcNifti, 'Enable', 'off');
- set(handles.CheckboxGroupAvgNormSrc, 'Enable', 'off');
- set(handles.CheckboxMakeGrpAvgNifti, 'Enable', 'off');
- end
- if strcmp(LoadBuilder.gui.MEGdataFiletype, 'AFNI')
- set(handles.CheckboxMakeSourceAfni, 'Enable', 'off');
- set(handles.CheckboxMakeNormSrcAfni, 'Enable', 'off');
- set(handles.CheckboxMakeGrpAvgAfni, 'Enable', 'off');
- end
- % Update PLS settings & GUI panels:
- handles = UpdatePLSmatInputData (handles);
- handles = UpdateTimeSettings (handles);
- handles = UpdateMaskSettings (handles);
- handles = UpdateBehaviorSettings (handles);
- handles = UpdatePLSrunSettings (handles);
- % Save handles:
- guidata(hObject, handles);
- close(WaitBox);
- %--- Textbox to display selected path of Builder: ---%
- %----------------------------------------------------%
- function TextboxBuilderMat_Callback(hObject, eventdata, handles)
- EnteredText = get(handles.TextboxBuilderMat, 'String');
- if ~isequal(EnteredText, handles.gui.BuilderMat)
- set(handles.TextboxBuilderMat, 'String', handles.gui.BuilderMat);
- msgbox('Note: Use the button to change Builder .mat file.')
- end
- %=======================================%
- % FUNCTIONS FOR SELECTING RUN SECTIONS: %
- %=======================================%
- %--- Checkboxes for timelock & frequency analysis: ---%
- %-----------------------------------------------------%
- % --- Executes on button press in CheckboxTimelockAnalysis.
- function CheckboxTimelockAnalysis_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxTimelockAnalysis, 'Value') == 1
- set(handles.CheckboxTimelockGrpAvg, 'Value', 1);
- end
- % --- Executes on button press in CheckboxTimelockGrpAvg.
- function CheckboxTimelockGrpAvg_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxFreqAnalysis.
- function CheckboxFreqAnalysis_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxFreqAnalysis, 'Value') == 1
- set(handles.CheckboxFreqGrpAvg, 'Value', 1);
- end
- % --- Executes on button press in CheckboxFreqGrpAvg.
- function CheckboxFreqGrpAvg_Callback(hObject, eventdata, handles)
- %--- Checkboxes for source analysis stream: ---%
- %----------------------------------------------%
- % --- Executes on button press in CheckboxSegmentMRI.
- function CheckboxSegmentMRI_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxHdmLeadfield.
- function CheckboxHdmLeadfield_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxSourceFilter.
- function CheckboxSourceFilter_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxSourceAnalysis.
- function CheckboxSourceAnalysis_Callback(hObject, eventdata, handles)
- % if get(handles.CheckboxSourceAnalysis, 'Value') == 1 %** Disabled for now
- % set(handles.CheckboxMakeSourceNifti, 'Value', 1); % Saves time
- % set(handles.CheckboxMakeSourceAfni, 'Value', 1);
- % else
- % set(handles.CheckboxMakeSourceNifti, 'Value', 0);
- % set(handles.CheckboxMakeSourceAfni, 'Value', 0);
- % end
- % --- Executes on button press in CheckboxMakeSourceNifti.
- function CheckboxMakeSourceNifti_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxMakeSourceAfni.
- function CheckboxMakeSourceAfni_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxNormaliseSource.
- function CheckboxNormaliseSource_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxNormaliseSource, 'Value') == 1
- set(handles.CheckboxMakeNormSrcNifti, 'Value', 1);
- set(handles.CheckboxMakeNormSrcAfni, 'Value', 1);
- else
- set(handles.CheckboxMakeNormSrcNifti, 'Value', 0);
- set(handles.CheckboxMakeNormSrcAfni, 'Value', 0);
- end
- % --- Executes on button press in CheckboxMakeNormSrcNifti.
- function CheckboxMakeNormSrcNifti_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxMakeNormSrcAfni.
- function CheckboxMakeNormSrcAfni_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxGroupAvgNormSrc. ---%
- function CheckboxGroupAvgNormSrc_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxGroupAvgNormSrc, 'Value') == 1
- set(handles.CheckboxMakeGrpAvgNifti, 'Value', 1);
- set(handles.CheckboxMakeGrpAvgAfni, 'Value', 1);
- else
- set(handles.CheckboxMakeGrpAvgNifti, 'Value', 0);
- set(handles.CheckboxMakeGrpAvgAfni, 'Value', 0);
- end
- % --- Executes on button press in CheckboxMakeGrpAvgNifti.
- function CheckboxMakeGrpAvgNifti_Callback(hObject, eventdata, handles)
- % --- Executes on button press in CheckboxMakeGrpAvgAfni.
- function CheckboxMakeGrpAvgAfni_Callback(hObject, eventdata, handles)
- %--- Executes on button press in CheckboxMakePLSmat. ---%
- %-------------------------------------------------------%
- function CheckboxMakePLSmat_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxMakePLSmat, 'Value') == 0
- set(handles.CheckboxRunPLS, 'Value', 0);
- end
- % Update GUI panels (to enable/disable):
- handles = UpdatePLSmatInputData (handles);
- handles = UpdateTimeSettings (handles);
- handles = UpdateMaskSettings (handles);
- handles = UpdateBehaviorSettings (handles);
- handles = UpdatePLSrunSettings (handles);
- % Save handles:
- guidata(hObject, handles);
- %--- Executes on button press in CheckboxRunPLS. ---%
- %---------------------------------------------------%
- function CheckboxRunPLS_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxRunPLS, 'Value') == 1
- set(handles.CheckboxMakePLSmat, 'Value', 1);
- end
- % Update GUI panels (to enable/disable):
- handles = UpdatePLSmatInputData (handles);
- handles = UpdateTimeSettings (handles);
- handles = UpdateMaskSettings (handles);
- handles = UpdateBehaviorSettings (handles);
- handles = UpdatePLSrunSettings (handles);
- % Save handles:
- guidata(hObject, handles);
- %======================================%
- % FUNCTIONS FOR OPENING VISUALIZATION: %
- %======================================%
- %--- Executes on button press in ButtonViewTimelockFreq. ---%
- %-----------------------------------------------------------%
- function ButtonViewTimelockFreq_Callback(hObject, eventdata, handles)
- VisualizeTimeFreq(handles.gui.BuilderMat);
- %--- Executes on button press in ButtonViewSources. ---%
- %------------------------------------------------------%
- function ButtonViewSources_Callback(hObject, eventdata, handles)
- VisualizeSourceData(handles.gui.BuilderMat);
- %--- Executes on button press in ButtonViewPLS. ---%
- %--------------------------------------------------%
- function ButtonViewPLS_Callback(hObject, eventdata, handles)
- ViewPLSresults
- %===================================%
- % FUNCTIONS FOR PLS INPUT SETTINGS: %
- %===================================%
- % --- Executes on selection change in ListboxPLSmatGroupID.
- function ListboxPLSmatGroupID_Callback(hObject, eventdata, handles)
- handles = UpdatePLSmatInputData(handles);
- guidata(hObject, handles);
- % --- Executes on selection change in ListboxPLSmatSubjID.
- function ListboxPLSmatSubjID_Callback(hObject, eventdata, handles)
- % --- Executes on selection change in ListboxPLSmatCondID.
- function ListboxPLSmatCondID_Callback(hObject, eventdata, handles)
- %--- Executes on button press in ButtonRmvPLSmatGroupID. ---%
- %--------------------------------------------------------%
- function ButtonRmvPLSmatGroupID_Callback(hObject, eventdata, handles)
- PLSmat = handles.PLSmat;
- if isempty(PLSmat.name.GroupID)
- return;
- end
- if length(PLSmat.name.GroupID) <= 1
- msgbox('Error: Cannot remove the last Group.', 'Error:')
- return;
- end
- % Exclude selected GroupID & data from PLSmat:
- SelectedIndex = get(handles.ListboxPLSmatGroupID, 'Value');
- PLSmat.name.GroupID (SelectedIndex) = [];
- PLSmat.name.SubjID (SelectedIndex) = [];
- PLSmat.paths.Afni4D (SelectedIndex) = [];
- PLSmat.paths.NormSource (SelectedIndex) = [];
- % Update GUI:
- handles.PLSmat = PLSmat;
- handles = UpdatePLSmatInputData(handles);
- % Save handles:
- guidata(hObject, handles);
- %--- Executes on button press in ButtonRmvPLSmatSubjID. ---%
- %----------------------------------------------------------%
- function ButtonRmvPLSmatSubjID_Callback(hObject, eventdata, handles)
- PLSmat = handles.PLSmat;
- if isempty(PLSmat.name.SubjID)
- return;
- end
- GroupIndex = get(handles.ListboxPLSmatGroupID, 'Value');
- if length(PLSmat.name.SubjID{GroupIndex}) <= 1
- msgbox('Error: Cannot remove the last Subject.', 'Error:');
- return;
- end
- % Exclude selected SubjID & data from PLSmat:
- SubjIndex = get(handles.ListboxPLSmatSubjID, 'Value');
- PLSmat.name.SubjID {GroupIndex}(SubjIndex) = [];
- PLSmat.paths.Afni4D {GroupIndex}(SubjIndex,:) = [];
- PLSmat.paths.NormSource {GroupIndex}(SubjIndex,:,:) = [];
- % Update GUI:
- handles.PLSmat = PLSmat;
- handles = UpdatePLSmatInputData(handles);
- % Save handles:
- guidata(hObject, handles);
- %--- Executes on button press in ButtonRmvPLSmatCondID. ---%
- %----------------------------------------------------------%
- function ButtonRmvPLSmatCondID_Callback(hObject, eventdata, handles)
- PLSmat = handles.PLSmat;
- if isempty(PLSmat.name.CondID)
- return;
- end
- if length(PLSmat.name.CondID) <= 1
- msgbox('Error: Cannot remove the last Condition.', 'Error:')
- return;
- end
- % Exclude selected CondID & data from PLSmat:
- SelectedIndex = get(handles.ListboxPLSmatCondID, 'Value');
- PLSmat.name.CondID(SelectedIndex) = [];
- for g = 1:length(PLSmat.name.GroupID)
- PLSmat.paths.Afni4D {g}(:,SelectedIndex) = [];
- PLSmat.paths.NormSource {g}(:,SelectedIndex,:) = [];
- end
- % Update GUI:
- handles.PLSmat = PLSmat;
- handles = UpdatePLSmatInputData(handles);
- % Save handles:
- guidata(hObject, handles);
- %--- Executes on button press in ButtonRestorePLSmatInput. ---%
- %-------------------------------------------------------------%
- function ButtonRestorePLSmatInput_Callback(hObject, eventdata, handles)
- PLSmat = handles.PLSmat;
- % Restore original Builder list of input data:
- PLSmat.name.GroupID = handles.name.GroupID;
- PLSmat.name.SubjID = handles.name.SubjID;
- PLSmat.name.CondID = handles.name.CondID;
- PLSmat.paths.Afni4D = handles.paths.Afni4DNormSource;
- PLSmat.paths.NormSource = handles.paths.NormSource;
- % Update GUI:
- handles.PLSmat = PLSmat;
- handles = UpdatePLSmatInputData(handles);
- % Save handles:
- guidata(hObject, handles);
- %--- Textbox for name ID of PLS session. ---%
- %-------------------------------------------%
- function TextboxPLSmatSessionID_Callback(hObject, eventdata, handles)
- InputID = deblank(get(handles.TextboxPLSmatSessionID, 'String'));
- InputID = regexprep(InputID, '\s+', '_');
- set(handles.TextboxPLSmatSessionID, 'String', InputID);
- handles = UpdatePLSmatInputData(handles);
- guidata(hObject, handles);
- %--- Update PLSmat input data & GUI panel: ---%
- %---------------------------------------------%
- function OutputHandles = UpdatePLSmatInputData(InputHandles)
- handles = InputHandles;
- PLSmat = handles.PLSmat;
- % Read GUI to update settings:
- PLSmat.SessionID = get(handles.TextboxPLSmatSessionID, 'String');
- % Update GroupID listbox:
- set(handles.ListboxPLSmatGroupID, 'String', PLSmat.name.GroupID);
- GroupIndex = get(handles.ListboxPLSmatGroupID, 'Value');
- MaxGroupIndex = length(PLSmat.name.GroupID);
- if isempty(GroupIndex) || GroupIndex == 0 || GroupIndex > MaxGroupIndex
- set(handles.ListboxPLSmatGroupID, 'Value', MaxGroupIndex);
- GroupIndex = MaxGroupIndex;
- end
- % Update SubjID listbox:
- if isempty(PLSmat.name.SubjID)
- set(handles.ListboxPLSmatSubjID, 'String', []);
- MaxSubjIndex = 0;
- else
- set(handles.ListboxPLSmatSubjID, 'String', PLSmat.name.SubjID{GroupIndex});
- MaxSubjIndex = length(PLSmat.name.SubjID{GroupIndex});
- end
- SubjIndex = get(handles.ListboxPLSmatSubjID, 'Value');
- if isempty(SubjIndex) || SubjIndex == 0 || SubjIndex > MaxSubjIndex
- set(handles.ListboxPLSmatSubjID, 'Value', MaxSubjIndex);
- end
- % Update CondID listbox:
- set(handles.ListboxPLSmatCondID, 'String', PLSmat.name.CondID);
- CondIndex = get(handles.ListboxPLSmatCondID, 'Value');
- MaxCondIndex = length(PLSmat.name.CondID);
- if isempty(CondIndex) || CondIndex == 0 || CondIndex > MaxCondIndex
- set(handles.ListboxPLSmatCondID, 'Value', MaxCondIndex);
- end
- % Enable/Disable GUI components:
- if get(handles.CheckboxMakePLSmat, 'Value') == 1
- set(findall(handles.PanelPLSmatInput, '-property', 'Enable'), 'Enable', 'on');
- else
- set(findall(handles.PanelPLSmatInput, '-property', 'Enable'), 'Enable', 'off');
-
- set(handles.ListboxPLSmatGroupID, 'Enable', 'on');
- set(handles.ListboxPLSmatSubjID, 'Enable', 'on');
- set(handles.ListboxPLSmatCondID, 'Enable', 'on');
-
- set(handles.TextHeaderPLSmatGroupIDs, 'Enable', 'on');
- set(handles.TextHeaderPLSmatSubjIDs, 'Enable', 'on');
- set(handles.TextHeaderPLSmatCondIDs, 'Enable', 'on');
- end
- % Set output handles:
- handles.PLSmat = PLSmat;
- OutputHandles = handles;
- %--- Reset PLSmat input data & GUI panel: ---%
- %--------------------------------------------%
- function OutputHandles = ResetPLSmatInputData(InputHandles)
- handles = InputHandles;
- PLSmat = handles.PLSmat;
- % Reset PLSmat input settings:
- PLSmat.name.GroupID = [];
- PLSmat.name.SubjID = [];
- PLSmat.name.CondID = [];
- PLSmat.paths.Afni4D = [];
- PLSmat.paths.NormSource = [];
- PLSmat.SessionID = [];
- % Reset GUI panel:
- set(handles.ListboxPLSmatGroupID, 'String', []);
- set(handles.ListboxPLSmatGroupID, 'Value', 1);
- set(handles.ListboxPLSmatSubjID, 'String', []);
- set(handles.ListboxPLSmatSubjID, 'Value', 1);
- set(handles.ListboxPLSmatCondID, 'String', []);
- set(handles.ListboxPLSmatCondID, 'Value', 1);
- set(handles.TextboxPLSmatSessionID, 'String', []);
- % Set output handles:
- handles.PLSmat = PLSmat;
- OutputHandles = handles;
- %======================================%
- % FUNCTIONS FOR PLS MAT TIME SETTINGS: %
- %======================================%
- %--- Executes on slider movement for PLS start time. ---%
- %-------------------------------------------------------%
- function SliderTimeStartPLS_Callback(hObject, eventdata, handles)
- if isempty(handles.gui.BuilderMat)
- msgbox('Warning: Load Builder .mat first.', 'Warning:');
- return;
- end
- StartIndex = round(get(handles.SliderTimeStartPLS, 'Value'));
- EndIndex = round(get(handles.SliderTimeEndPLS, 'Value'));
- if StartIndex > EndIndex
- StartIndex = EndIndex;
- end
- set(handles.SliderTimeStartPLS, 'Value', StartIndex);
- set(handles.TextboxTimeStartPLS, 'String', handles.time.str.Windows{StartIndex,1});
- handles = UpdateTimeSettings(handles);
- guidata(hObject, handles);
- %--- Executes on slider movement for PLS end time. ---%
- %-----------------------------------------------------%
- function SliderTimeEndPLS_Callback(hObject, eventdata, handles)
- if isempty(handles.gui.BuilderMat)
- return;
- end
- EndIndex = round(get(handles.SliderTimeEndPLS, 'Value'));
- StartIndex = round(get(handles.SliderTimeStartPLS, 'Value'));
- if EndIndex < StartIndex
- EndIndex = StartIndex;
- end
- set(handles.SliderTimeEndPLS, 'Value', EndIndex);
- set(handles.TextboxTimeEndPLS, 'String', handles.time.str.Windows{EndIndex,2});
- handles = UpdateTimeSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to display or enter PLS start time: ---%
- %---------------------------------------------------%
- function TextboxTimeStartPLS_Callback(hObject, eventdata, handles)
- if isempty(handles.gui.BuilderMat)
- return;
- end
- % Check input start time:
- InputStartTime = str2num(get(handles.TextboxTimeStartPLS, 'String'));
- InputEndTime = str2num(get(handles.TextboxTimeEndPLS, 'String'));
- if isempty(InputStartTime) || InputStartTime > InputEndTime
- StartIndex = get(handles.SliderTimeStartPLS, 'Value');
- set(handles.TextboxTimeStartPLS, 'String', handles.time.str.Windows{StartIndex,1});
- end
- % Find closest time-index:
- [~, ClosestIndex] = min(abs(InputStartTime - handles.time.Windows(:,1)));
- StartIndex = ClosestIndex;
- if StartIndex > EndIndex;
- StartIndex = EndIndex;
- end
- set(handles.SliderTimeStartPLS, 'Value', StartIndex);
- set(handles.TextboxTimeStartPLS, 'String', handles.time.str.Windows{StartIndex,1});
- % Save handles:
- handles = UpdateTimeSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to display or enter PLS end time: ---%
- %-------------------------------------------------%
- function TextboxTimeEndPLS_Callback(hObject, eventdata, handles)
- if isempty(handles.gui.BuilderMat)
- return;
- end
- % Check input end time:
- InputStartTime = str2num(get(handles.TextboxTimeStartPLS, 'String'));
- InputEndTime = str2num(get(handles.TextboxTimeEndPLS, 'String'));
- if isempty(InputEndTime) || InputEndTime < InputStartTime
- EndIndex = get(handles.SliderTimeEndPLS, 'Value');
- set(handles.TextboxTimeEndPLS, 'String', handles.time.str.Windows{EndIndex,2});
- end
- % Find closest time-index:
- [~, ClosestIndex] = min(abs(EndTime - handles.time.Windows(:,2)));
- EndIndex = ClosestIndex;
- if EndIndex < StartIndex
- EndIndex = StartIndex;
- end
- set(handles.SliderTimeEndPLS, 'Value', EndIndex);
- set(handles.TextboxTimeEndPLS, 'String', handles.time.str.Windows{EndIndex,2});
- % Save handles:
- handles = UpdateTimeSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in CheckboxManualTimeSelect. ---%
- %---------------------------------------------------------------%
- function CheckboxManualTimeSelect_Callback(hObject, eventdata, handles)
- handles = UpdateTimeSettings(handles);
- guidata(hObject, handles);
- % --- Executes on selection change in ListboxManualTimeSelect.
- function ListboxManualTimeSelect_Callback(hObject, eventdata, handles)
- %--- Executes on button press in ButtonManualTimeSelect. ---%
- %--------------------------------------------------------------%
- function ButtonManualTimeSelect_Callback(hObject, eventdata, handles)
- if isempty(handles.gui.BuilderMat)
- return;
- end
- SelectedIndices = listdlg('PromptString', 'Select time-indices for PLS analysis:',...
- 'ListSize', [300, 300], 'SelectionMode', 'multiple',...
- 'ListString', handles.time.str.Windows(:,3));
- if isempty(SelectedIndices)
- return; % If user cancels
- end
- SelectedIndices = sort(SelectedIndices);
- handles.gui.ManualTimeIndices = SelectedIndices; % Keep in memory for switch-back
- handles = UpdateTimeSettings(handles);
- guidata(hObject, handles);
- %--- Updates time settings & GUI panel: ---%
- %------------------------------------------%
- function OutputHandles = UpdateTimeSettings(InputHandles)
- handles = InputHandles;
- % Read GUI to update PLSmat:
- if get(handles.CheckboxManualTimeSelect, 'Value') == 0
- StartTimeIndex = round(get(handles.SliderTimeStartPLS, 'Value'));
- EndTimeIndex = round(get(handles.SliderTimeEndPLS, 'Value'));
-
- handles.PLSmat.TimeIndices = [StartTimeIndex:EndTimeIndex];
- handles.PLSmat.ManualTimeSelect = 'no';
- else
- handles.PLSmat.TimeIndices = handles.gui.ManualTimeIndices;
- handles.PLSmat.ManualTimeSelect = 'yes';
- end
- % Update listbox:
- if isempty(handles.gui.ManualTimeIndices)
- set(handles.ListboxManualTimeSelect, 'String', []);
- else
- set(handles.ListboxManualTimeSelect, 'String',...
- handles.time.str.Windows(handles.gui.ManualTimeIndices, 3));
- end
- SelectedIndex = get(handles.ListboxManualTimeSelect, 'Value');
- MaxListIndex = length(handles.gui.ManualTimeIndices);
- if isempty(SelectedIndex) || SelectedIndex == 0 || SelectedIndex > MaxListIndex
- set(handles.ListboxManualTimeSelect, 'Value', MaxListIndex);
- end
- % Enable/Disable GUI time components:
- if get(handles.CheckboxMakePLSmat, 'Value') == 1
- set(findall(handles.PanelPLSTimeSettings, '-property', 'Enable'), 'Enable', 'on');
- else
- set(findall(handles.PanelPLSTimeSettings, '-property', 'Enable'), 'Enable', 'off');
- end
- if size(handles.time.Windows, 1) == 1
- set(handles.SliderTimeStartPLS, 'Enable', 'off');
- set(handles.SliderTimeEndPLS, 'Enable', 'off');
- set(handles.TextboxTimeStartPLS, 'Enable', 'off');
- set(handles.TextboxTimeEndPLS, 'Enable', 'off');
- set(handles.TextTimeStartHeaderPLS, 'Enable', 'off');
- set(handles.TextTimeEndHeaderPLS, 'Enable', 'off');
- end
- if get(handles.CheckboxManualTimeSelect, 'Value') == 0
- set(handles.ButtonManualTimeSelect, 'Enable', 'off');
- set(handles.ListboxManualTimeSelect, 'Enable', 'off');
- else
- set(handles.SliderTimeStartPLS, 'Enable', 'off');
- set(handles.SliderTimeEndPLS, 'Enable', 'off');
- set(handles.TextboxTimeStartPLS, 'Enable', 'off');
- set(handles.TextboxTimeEndPLS, 'Enable', 'off');
- set(handles.TextTimeStartHeaderPLS, 'Enable', 'off');
- set(handles.TextTimeEndHeaderPLS, 'Enable', 'off');
- end
- % Set output handles:
- OutputHandles = handles;
- %--- Reset time settings & GUI panel: ---%
- %----------------------------------------%
- function OutputHandles = ResetTimeSettings(InputHandles)
- handles = InputHandles;
- % Reset PLSmat time settings:
- handles.PLSmat.TimeIndices = [1:size(handles.time.Windows, 1)];
- handles.PLSmat.ManualTimeSelect = 'no';
- handles.gui.ManualTimeIndices = [];
- % Reset GUI time panel back to default:
- SliderStep = 1 / size(handles.time.Windows, 1);
- set(handles.CheckboxManualTimeSelect, 'Value', 0);
- set(handles.ListboxManualTimeSelect, 'String', []);
- set(handles.SliderTimeStartPLS, 'Min', 1);
- set(handles.SliderTimeStartPLS, 'Max', size(handles.time.Windows, 1));
- set(handles.SliderTimeStartPLS, 'SliderStep', [SliderStep SliderStep]);
- set(handles.SliderTimeStartPLS, 'Value', 1);
- set(handles.SliderTimeEndPLS, 'Min', 1);
- set(handles.SliderTimeEndPLS, 'Max', size(handles.time.Windows, 1));
- set(handles.SliderTimeEndPLS, 'SliderStep', [SliderStep SliderStep]);
- set(handles.SliderTimeEndPLS, 'Value', size(handles.time.Windows, 1));
- set(handles.TextboxTimeStartPLS, 'String', handles.time.str.Windows{1,1});
- set(handles.TextboxTimeEndPLS, 'String', handles.time.str.Windows{end,2});
- % Set output handles:
- OutputHandles = handles;
- %======================================%
- % FUNCTIONS FOR PLS MAT MASK SETTINGS: %
- %======================================%
- %--- Executes on button-group in PanelPLSMaskSettings. ---%
- %---------------------------------------------------------%
- function PanelPLSMaskSettings_SelectionChangeFcn(hObject, eventdata, handles)
- handles = UpdateMaskSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in CheckboxDataSpecificMask. ---%
- %-------------------------------------------------------------%
- function CheckboxDataSpecificMask_Callback(hObject, eventdata, handles)
- handles = UpdateMaskSettings(handles);
- guidata(hObject, handles);
- %--- User enters % threshold to keep voxels for data-specific mask: ---%
- %----------------------------------------------------------------------%
- function TextboxKeepVoxelThresh_Callback(hObject, eventdata, handles)
- if isempty(get(handles.TextboxKeepVoxelThresh, 'String'))
- msgbox('Error: Voxel inclusion threshold not specified. Default set to 90%.');
- set(handles.TextboxROISize, 'String', num2str(1));
- end
- handles = UpdateMaskSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in ButtonSelectBrainMask. ---%
- %----------------------------------------------------------%
- function ButtonSelectBrainMask_Callback(hObject, eventdata, handles)
- % Get initial search path:
- if ~isempty(handles.PLSmat.BrainMaskFile)
- [SearchPath, ~, ~] = fileparts(handles.gui.DefaultBrainMask);
- else
- [SearchPath, ~, ~] = fileparts(handles.PLSmat.BrainMaskFile);
- end
- % Select brain mask:
- [MaskFile, MaskPath] = uigetfile([SearchPath,'/*+tlrc.BRIK'],...
- 'Select Mask File:', 'MultiSelect', 'off');
- if MaskFile == 0
- return; % If user cancels
- end
- handles.PLSmat.BrainMaskFile = [MaskPath,MaskFile];
- set(handles.TextboxBrainMaskFile, 'String', handles.PLSmat.BrainMaskFile);
- % Save handles:
- handles = UpdateMaskSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to display selected brain mask. ---%
- %-----------------------------------------------%
- function TextboxBrainMaskFile_Callback(hObject, eventdata, handles)
- EnteredText = get(handles.TextboxBrainMaskFile, 'String');
- if ~isequal(EnteredText, handles.PLSmat.BrainMaskFile)
- set(handles.TextboxBrainMaskFile, 'String', handles.PLSmat.BrainMaskFile);
- msgbox('Note: Use the button to change brain mask file.', 'Note:');
- end
- %--- Executes on button press in ButtonSelectROIMask. ---%
- %--------------------------------------------------------%
- function ButtonSelectROIMask_Callback(hObject, eventdata, handles)
- % Get initial search path:
- if ~isempty(handles.PLSmat.ROIMaskFile)
- [SearchPath, ~, ~] = fileparts(handles.gui.DefaultROIMask);
- else
- [SearchPath, ~, ~] = fileparts(handles.PLSmat.ROIMaskFile);
- end
- % Select ROI mask:
- [MaskFile, MaskPath] = uigetfile([SearchPath,'/*.xls'],...
- 'Select Mask File:', 'MultiSelect', 'off');
- if MaskFile == 0
- return; % If user cancels
- end
- handles.PLSmat.ROIMaskFile = [MaskPath,MaskFile];
- set(handles.TextboxROIMaskFile, 'String', handles.PLSmat.ROIMaskFile);
- % Save handles:
- handles = UpdateMaskSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to display selected ROI mask. ---%
- %---------------------------------------------%
- function TextboxROIMaskFile_Callback(hObject, eventdata, handles)
- EnteredText = get(handles.TextboxROIMaskFile, 'String');
- if ~isequal(EnteredText, handles.PLSmat.ROIMaskFile)
- set(handles.TextboxROIMaskFile, 'String', handles.PLSmat.ROIMaskFile);
- msgbox('Note: Use the button to change ROI mask file.', 'Note:');
- end
- %--- Textbox to specify ROI voxel size: ---%
- %------------------------------------------%
- function TextboxROISize_Callback(hObject, eventdata, handles)
- if isempty(get(handles.TextboxROISize, 'String'))
- msgbox('Error: ROI size for ROI mask not specified. Default set to 1.');
- set(handles.TextboxROISize, 'String', num2str(1));
- end
- if str2num(get(handles.TextboxROISize, 'String')) == 0
- msgbox('Error: ROI size for ROI mask cannot be 0. Default set to 1.');
- set(handles.TextboxROISize, 'String', num2str(1));
- end
- handles = UpdateMaskSettings(handles);
- guidata(hObject, handles);
- %--- Updates mask settings & GUI panel: ---%
- %------------------------------------------%
- function OutputHandles = UpdateMaskSettings(InputHandles)
- handles = InputHandles;
- % Read GUI to update PLSmat:
- if get(handles.ButtonBrainMask, 'Value') == 1
- handles.PLSmat.MaskType = 'BrainMask';
- elseif get(handles.ButtonROIMask, 'Value') == 1
- handles.PLSmat.MaskType = 'ROIMask';
- end
- if get(handles.CheckboxDataSpecificMask, 'Value') == 1
- handles.PLSmat.DataSpecificMask = 'yes';
- else
- handles.PLSmat.DataSpecificMask = 'no';
- end
- handles.PLSmat.MaskKeepVoxThresh = ...
- str2num(get(handles.TextboxKeepVoxelThresh, 'String')) / 100;
- ROISize = round(str2num(get(handles.TextboxROISize, 'String')));
- handles.PLSmat.ROIBlobSize = [-ROISize:ROISize];
- % Enable/Disable GUI mask components:
- if get(handles.CheckboxMakePLSmat, 'Value') == 1
- set(findall(handles.PanelPLSMaskSettings, '-property', 'Enable'), 'Enable', 'on');
- %set(handles.TextboxBrainMaskFile, 'Enable', 'inactive');
- %set(handles.TextboxROIMaskFile, 'Enable', 'inactive');
- else
- set(findall(handles.PanelPLSMaskSettings, '-property', 'Enable'), 'Enable', 'off');
- end
- if get(handles.ButtonBrainMask, 'Value') == 1
- if get(handles.CheckboxDataSpecificMask, 'Value') == 1
- set(handles.ButtonSelectBrainMask, 'Enable', 'off');
- set(handles.TextboxBrainMaskFile, 'Enable', 'off');
- else
- set(handles.TextboxKeepVoxelThresh, 'Enable', 'off');
- set(handles.TextKeepVoxelThresh, 'Enable', 'off');
- end
-
- set(handles.ButtonSelectROIMask, 'Enable', 'off');
- set(handles.TextboxROIMaskFile, 'Enable', 'off');
- set(handles.TextboxROISize, 'Enable', 'off');
- set(handles.TextROISize, 'Enable', 'off');
-
- elseif get(handles.ButtonROIMask, 'Value') == 1
- set(handles.CheckboxDataSpecificMask, 'Enable', 'off');
- set(handles.ButtonSelectBrainMask, 'Enable', 'off');
- set(handles.TextboxBrainMaskFile, 'Enable', 'off');
- set(handles.TextboxKeepVoxelThresh, 'Enable', 'off');
- set(handles.TextKeepVoxelThresh, 'Enable', 'off');
- end
- % Set output handles:
- OutputHandles = handles;
- %--- Reset mask settings & GUI panel: ---%
- %----------------------------------------%
- function OutputHandles = ResetMaskSettings(InputHandles)
- handles = InputHandles;
- % Reset PLSmat mask settings:
- handles.PLSmat.MaskType = 'BrainMask';
- handles.PLSmat.DataSpecificMask = 'yes';
- handles.PLSmat.MaskKeepVoxThresh = 0.90;
- handles.PLSmat.BrainMaskFile = handles.gui.DefaultBrainMask;
- handles.PLSmat.ROIMaskFile = handles.gui.DefaultROIMask;
- handles.PLSmat.ROIBlobSize = [-1:1];
- % Reset GUI mask panel back to default:
- set(handles.ButtonBrainMask, 'Value', 1);
- set(handles.ButtonROIMask, 'Value', 0);
- set(handles.TextboxROISize, 'String', num2str(1));
- set(handles.TextboxBrainMaskFile, 'String', handles.gui.DefaultBrainMask);
- set(handles.TextboxROIMaskFile, 'String', handles.gui.DefaultROIMask);
- set(handles.CheckboxDataSpecificMask, 'Value', 1);
- set(handles.TextboxKeepVoxelThresh, 'String', '90');
- % Set output handles:
- OutputHandles = handles;
- %====================================%
- % FUNCTIONS FOR BEHAVIOR & SEED PLS: %
- %====================================%
- %--- Textbox for name ID of behavior files loaded. ---%
- %-----------------------------------------------------%
- function TextboxBhvSeedID_Callback(hObject, eventdata, handles)
- InputID = deblank(get(handles.TextboxBhvSeedID, 'String'));
- InputID = regexprep(InputID, '\s+', '_');
- set(handles.TextboxBhvSeedID, 'String', InputID);
- handles = UpdateBehaviorSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in ButtonLoadBhvFile. ---%
- %------------------------------------------------------%
- function ButtonLoadBhvFile_Callback(hObject, eventdata, handles)
- if ~isempty(handles.PLSmat.BhvFile)
- [SearchPath, ~, ~] = fileparts(handles.PLSmat.BhvFile);
- SearchPath = [SearchPath,'/'];
- else
- SearchPath = [];
- end
- [BhvFile, BhvPath] = uigetfile([SearchPath,'*.xls'],...
- 'Select Behavior file:', 'MultiSelect', 'off');
- if BhvFile == 0
- return; % If user cancels
- end
- handles.PLSmat.BhvFile = [BhvPath,BhvFile];
- set(handles.TextboxBhvFile, 'String', handles.PLSmat.BhvFile);
- handles = UpdateBehaviorSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in ButtonClearBhvFile. ---%
- %-------------------------------------------------------%
- function ButtonClearBhvFile_Callback(hObject, eventdata, handles)
- handles.PLSmat.BhvFile = [];
- set(handles.TextboxBhvFile, 'String', []);
- handles = UpdateBehaviorSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to display selected behavior .xls. ---%
- %--------------------------------------------------%
- function TextboxBhvFile_Callback(hObject, eventdata, handles)
- EnteredText = get(handles.TextboxBhvFile, 'String');
- if ~isequal(EnteredText, handles.PLSmat.BhvFile)
- set(handles.TextboxBhvFile, 'String', handles.PLSmat.BhvFile);
- msgbox('Note: Use button to change bhv .xls file.', 'Note:');
- end
- %--- Executes on button press in ButtonLoadSeedFile. ---%
- %-------------------------------------------------------%
- function ButtonLoadSeedFile_Callback(hObject, eventdata, handles)
- if ~isempty(handles.PLSmat.SeedFile)
- [SearchPath, ~, ~] = fileparts(handles.PLSmat.SeedFile);
- SearchPath = [SearchPath,'/'];
- else
- SearchPath = [];
- end
- [SeedFile, SeedPath] = uigetfile([SearchPath,'*.xls'],...
- 'Select Seed file:', 'MultiSelect', 'off');
- if SeedFile == 0
- return; % If user cancels
- end
- handles.PLSmat.SeedFile = [SeedPath,SeedFile];
- set(handles.TextboxSeedFile, 'String', handles.PLSmat.SeedFile);
- handles = UpdateBehaviorSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in ButtonClearSeedFile. ---%
- %--------------------------------------------------------%
- function ButtonClearSeedFile_Callback(hObject, eventdata, handles)
- handles.PLSmat.SeedFile = [];
- set(handles.TextboxSeedFile, 'String', []);
- handles = UpdateBehaviorSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to display selected seed .xls. ---%
- %----------------------------------------------%
- function TextboxSeedFile_Callback(hObject, eventdata, handles)
- EnteredText = get(handles.TextboxSeedFile, 'String');
- if ~isequal(EnteredText, handles.PLSmat.SeedFile)
- set(handles.TextboxSeedFile, 'String', handles.PLSmat.SeedFile);
- msgbox('Note: Use button to change seed .xls file.');
- end
- %--- Textbox to specify seed size. ---%
- %-------------------------------------%
- function TextboxSeedSize_Callback(hObject, eventdata, handles)
- if isempty(get(handles.TextboxSeedSize, 'String'))
- msgbox('Error: Seed size for seeds not specified. Default set to 1.', 'Error:')
- set(handles.TextboxSeedSize, 'String', num2str(1));
- end
- if str2num(get(handles.TextboxSeedSize, 'String')) == 0
- msgbox('Error: Seed size for seeds cannot be 0. Default set to 1.', 'Error:')
- set(handles.TextboxSeedSize, 'String', num2str(1));
- end
- handles = UpdateBehaviorSettings(handles);
- guidata(hObject, handles);
- %--- Updates behavior settings & GUI panel. ---%
- %----------------------------------------------%
- function OutputHandles = UpdateBehaviorSettings(InputHandles)
- handles = InputHandles;
- % Read GUI to update PLSmat:
- handles.PLSmat.BhvSeedID = get(handles.TextboxBhvSeedID, 'String');
- SeedSize = round(str2num(get(handles.TextboxSeedSize, 'String')));
- handles.PLSmat.SeedBlobSize = [-SeedSize:SeedSize];
- % Enable/disable GUI behavior components:
- if get(handles.CheckboxMakePLSmat, 'Value') == 1
- set(findall(handles.PanelPLSBhvSeedSettings, '-property', 'Enable'), 'Enable', 'on');
- %set(handles.TextboxBhvFile, 'Enable', 'inactive');
- %set(handles.TextboxSeedFile, 'Enable', 'inactive');
- else
- set(findall(handles.PanelPLSBhvSeedSettings, '-property', 'Enable'), 'Enable', 'off');
- end
- if isempty(handles.PLSmat.SeedFile)
- set(handles.TextboxSeedSize, 'Enable', 'off');
- set(handles.TextSeedSize, 'Enable', 'off');
- end
- % Set output handles:
- OutputHandles = handles;
- %--- Reset behavior settings & GUI panel. ---%
- %--------------------------------------------%
- function OutputHandles = ResetBehaviorSettings(InputHandles)
- handles = InputHandles;
- % Reset PLSmat behavior settings:
- handles.PLSmat.BhvSeedID = [];
- handles.PLSmat.BhvFile = [];
- handles.PLSmat.SeedFile = [];
- handles.PLSmat.SeedBlobSize = [-1:1];
- % Reset GUI behavior panel back to default:
- set(handles.TextboxBhvSeedID, 'String', []);
- set(handles.TextboxBhvFile, 'String', []);
- set(handles.TextboxSeedFile, 'String', []);
- set(handles.TextboxSeedSize, 'String', num2str(1));
- % Set output handles:
- OutputHandles = handles;
- %=====================================%
- % GUI FUNCTIONS FOR PLS RUN SETTINGS: %
- %=====================================%
- %--- Executes on button press in ButtonPLSReadme. ---%
- %----------------------------------------------------%
- function ButtonPLSReadme_Callback(hObject, eventdata, handles)
- [PipelineDir, ~, ~] = fileparts(which('DriverGUI.m'));
- open([PipelineDir,'/MEGPLS_TOOLBOX/PLS_Tools/pls_nk_functions/PLS_README.txt']);
- %--- Executes on selection change in DropdownPLSMethod. ---%
- %----------------------------------------------------------%
- function DropdownPLSMethod_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in CheckboxSplitHalfPLS. ---%
- %---------------------------------------------------------%
- function CheckboxSplitHalfPLS_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxSplitHalfPLS, 'Value') == 1
- set(handles.TextboxNumSplits, 'String', num2str(100));
- set(handles.TextboxNumPermutations, 'String', num2str(100));
- set(handles.TextboxNumBootstraps, 'String', num2str(200));
- else
- set(handles.TextboxNumSplits, 'String', num2str(0));
- set(handles.TextboxNumPermutations, 'String', num2str(500));
- set(handles.TextboxNumBootstraps, 'String', num2str(500));
- end
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to specify number of PLS splits. ---%
- %------------------------------------------------%
- function TextboxNumSplits_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxSplitHalfPLS, 'Value') == 1
- if isempty(get(handles.TextboxNumSplits, 'String'))
- msgbox('Note: Number of splits not specified. Default set to 100.')
- set(handles.TextboxNumSplits, 'String', num2str(100));
- end
- if str2num(get(handles.TextboxNumSplits, 'String')) > 100
- msgbox('Warning: For Splithalf-PLS, recommend # splits to be < 100.')
- end
- elseif get(handles.CheckboxSplitHalfPLS, 'Value') == 0
- set(handles.TextboxNumSplits, 'String', num2str(0));
- end
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to specify number of PLS permutations. ---%
- %------------------------------------------------------%
- function TextboxNumPermutations_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxSplitHalfPLS, 'Value') == 1
- if isempty(get(handles.TextboxNumPermutations, 'String'))
- msgbox('Note: Number of permutations not specified. Default set to 100.')
- set(handles.TextboxNumPermutations, 'String', num2str(100));
- end
- if str2num(get(handles.TextboxNumPermutations, 'String')) > 100
- msgbox('Warning: For Splithalf-PLS, recommend # perm. to be < 100.')
- end
-
- elseif get(handles.CheckboxSplitHalfPLS, 'Value') == 0
- if isempty(get(handles.TextboxNumPermutations, 'String'))
- msgbox('Note: Number of permutations not specified. Default set to 500.')
- set(handles.TextboxNumPermutations, 'String', num2str(500));
- end
- end
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to specify number of PLS bootstraps. ---%
- %------------------------------------------------------%
- function TextboxNumBootstraps_Callback(hObject, eventdata, handles)
- if get(handles.CheckboxSplitHalfPLS, 'Value') == 1
- if isempty(get(handles.TextboxNumBootstraps, 'String'))
- msgbox('Note: Number of bootstraps not specified. Default set to 200.')
- set(handles.TextboxNumBootstraps, 'String', num2str(200));
- end
- if str2num(get(handles.TextboxNumBootstraps, 'String')) > 200
- msgbox('Warning: For Splithalf-PLS, recommend # perm. to be < 200.')
- end
- elseif get(handles.CheckboxSplitHalfPLS, 'Value') == 0
- if isempty(get(handles.TextboxNumBootstraps, 'String'))
- msgbox('Note: Number of bootstraps not specified. Default set to 500.')
- set(handles.TextboxNumBootstraps, 'String', num2str(500));
- end
- end
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Textbox to enter PLS non-rotated contrast. ---%
- %--------------------------------------------------%
- function TextboxNRContrast_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Textbox for name ID of PLS non-rotated contrast. ---%
- %--------------------------------------------------------%
- function TextboxNRContrastID_Callback(hObject, eventdata, handles)
- InputID = deblank(get(handles.TextboxNRContrastID, 'String'));
- InputID = regexprep(InputID, '\s+', '_');
- set(handles.TextboxNRContrastID, 'String', InputID);
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in CheckboxSingleBhv. ---%
- %------------------------------------------------------%
- function CheckboxSingleBhv_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on button press in CheckboxKeepDatamat. ---%
- %--------------------------------------------------------%
- function CheckboxKeepDatamat_Callback(hObject, eventdata, handles)
- prompt = {'WARNING:';
- 'Saving datamat will consume a large amount of HDD space.';
- 'Are you sure you want to enable setting?'};
- SaveDatamat = questdlg(prompt, 'WARNING:', 'YES', 'NO', 'NO');
- if strcmp(SaveDatamat, 'NO')
- set(handles.CheckboxKeepDatamat, 'Value', 0);
- return;
- end
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on selection change in DropdownMCentType. ---%
- %----------------------------------------------------------%
- function DropdownMCentType_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on selection change in DropdownCorrMode. ---%
- %---------------------------------------------------------%
- function DropdownCorrMode_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on selection change in DropdownPermType. ---%
- %---------------------------------------------------------%
- function DropdownPermType_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Executes on selection change in DropdownBootType. ---%
- %---------------------------------------------------------%
- function DropdownBootType_Callback(hObject, eventdata, handles)
- handles = UpdatePLSrunSettings(handles);
- guidata(hObject, handles);
- %--- Updates PLSrun settings & GUI panel. ---%
- %----------------------------------------------%
- function OutputHandles = UpdatePLSrunSettings(InputHandles)
- handles = InputHandles;
- % Read GUI to update PLSrun settings:
- DropdownOptions = get(handles.DropdownPLSMethod, 'String');
- PLSMethod = DropdownOptions{get(handles.DropdownPLSMethod, 'Value')};
- switch PLSMethod
- case 'Mean-Centered'
- handles.PLSrun.Method = 'MCENT';
- case 'Non-Rotated'
- handles.PLSrun.Method = 'NROT';
- case 'Behavior/Seed'
- handles.PLSrun.Method = 'BHV';
- case 'Multi-Block'
- handles.PLSrun.Method = 'MBLOCK';
- case 'NRot. Behavior'
- handles.PLSrun.Method = 'NR-BHV';
- case 'NRot. Multi-Block'
- handles.PLSrun.Method = 'NR-MBLOCK';
- end
- handles.PLSrun.NumPerm = str2num(get(handles.TextboxNumPermutations, 'String'));
- handles.PLSrun.NumBoot = str2num(get(handles.TextboxNumBootstraps, 'String'));
- handles.PLSrun.NumSplit = str2num(get(handles.TextboxNumSplits, 'String'));
- handles.PLSrun.NRContrast = str2num(get(handles.TextboxNRContrast, 'String'));
- handles.PLSrun.NRContrastID = get(handles.TextboxNRContrastID, 'String');
- if get(handles.CheckboxKeepDatamat, 'Value') == 1
- handles.PLSrun.KeepDatamat = 'yes';
- else
- handles.PLSrun.KeepDatamat = 'no';
- end
- if get(handles.CheckboxSplitHalfPLS, 'Value') == 1
- handles.PLSrun.SplitHalf = 'yes';
- else
- handles.PLSrun.SplitHalf = 'no';
- handles.PLSrun.NumSplit = 0;
- end
- if get(handles.CheckboxSingleBhv, 'Value') == 1 && ...
- ismember(handles.PLSrun.Method, {'BHV', 'MBLOCK', 'NR-BHV', 'NR-MBLOCK'})
- handles.PLSrun.SingleBhv = 'yes';
- else
- handles.PLSrun.SingleBhv = 'no';
- end
- DropdownOptions = get(handles.DropdownMCentType, 'String');
- MCentType = DropdownOptions{get(handles.DropdownMCentType, 'Value')};
- handles.PLSrun.MCentType = str2num(MCentType);
- DropdownOptions = get(handles.DropdownCorrMode, 'String');
- CorrMode = DropdownOptions{get(handles.DropdownCorrMode, 'Value')};
- handles.PLSrun.CorrMode = str2num(CorrMode);
- DropdownOptions = get(handles.DropdownPermType, 'String');
- PermType = DropdownOptions{get(handles.DropdownPermType, 'Value')};
- handles.PLSrun.PermType = str2num(PermType);
- DropdownOptions = get(handles.DropdownBootType, 'String');
- BootType = DropdownOptions{get(handles.DropdownBootType, 'Value')};
- switch BootType
- case 'stratified'
- handles.PLSrun.BootType = 'strat';
- case 'non-stratified'
- handles.PLSrun.BootType = 'nonstrat';
- otherwise
- error('Unrecognized option.') % error-check
- end
- % Enable/disable GUI PLSrun components:
- if get(handles.CheckboxRunPLS, 'Value') == 1
- set(findall(handles.PanelPLSrunSettings, '-property', 'Enable'), 'Enable', 'on');
- else
- set(findall(handles.PanelPLSrunSettings, '-property', 'Enable'), 'Enable', 'off');
- end
- if ~ismember(handles.PLSrun.Method, {'MCENT', 'NROT', 'MBLOCK', 'NR-MBLOCK'})
- set(handles.DropdownMCentType, 'Enable', 'off');
- set(handles.TextMCentType, 'Enable', 'off');
- end
- if ~ismember(handles.PLSrun.Method, {'NROT', 'NR-BHV', 'NR-MBLOCK'})
- set(handles.TextboxNRContrast, 'Enable', 'off');
- set(handles.TextboxNRContrastID, 'Enable', 'off');
- set(handles.TextNRContrastID, 'Enable', 'off');
- end
- if ~ismember(handles.PLSrun.Method, {'BHV', 'MBLOCK', 'NR-BHV', 'NR-MBLOCK'})
- set(handles.CheckboxSingleBhv, 'Enable', 'off');
- end
- if get(handles.CheckboxSplitHalfPLS, 'Value') == 0
- set(handles.TextboxNumSplits, 'Enable', 'off');
- set(handles.TextNumSplits, 'Enable', 'off');
- end
- % Set output handles:
- OutputHandles = handles;
- %--- Reset PLSrun settings & GUI panel. ---%
- %------------------------------------------%
- function OutputHandles = ResetPLSrunSettings(InputHandles)
- handles = InputHandles;
- % Reset PLSrun settings:
- handles.PLSrun.Method = 'MCENT';
- handles.PLSrun.NumPerm = 500;
- handles.PLSrun.NumBoot = 500;
- handles.PLSrun.NumSplit = 0;
- handles.PLSrun.NRContrast = [];
- handles.PLSrun.NRContrastID = [];
- handles.PLSrun.KeepDatamat = 'no';
- handles.PLSrun.SplitHalf = 'no';
- handles.PLSrun.SingleBhv = 'no';
- handles.PLSrun.MCentType = 0;
- handles.PLSrun.CorrMode = 0;
- handles.PLSrun.PermType = 0;
- handles.PLSrun.BootType = 'strat';
- % Reset GUI PLSrun panel back to default:
- DropdownOptions = get(handles.DropdownPLSMethod, 'String');
- DropdownValue = find(strcmp(DropdownOptions, 'Mean-Centered'));
- set(handles.DropdownPLSMethod, 'Value', DropdownValue);
- if DropdownValue == 0
- error('Option does not exist in dropdown list.'); % Error-check
- end
- set(handles.TextboxNumPermutations, 'String', num2str(500));
- set(handles.TextboxNumBootstraps, 'String', num2str(500));
- set(handles.TextboxNumSplits, 'String', num2str(0));
- set(handles.TextboxNRContrast, 'String', []);
- set(handles.TextboxNRContrastID, 'String', []);
- set(handles.CheckboxSplitHalfPLS, 'Value', 0);
- set(handles.CheckboxSingleBhv, 'Value', 0);
- set(handles.CheckboxKeepDatamat, 'Value', 0);
- set(handles.DropdownMCentType, 'Value', 1); % Sets type to 0.
- set(handles.DropdownCorrMode, 'Value', 1); % Sets type to 0.
- set(handles.DropdownPermType, 'Value', 1); % Sets type to 0.
- DropdownOptions = get(handles.DropdownBootType, 'String');
- DropdownValue = find(strcmp(DropdownOptions, 'stratified'));
- set(handles.DropdownBootType, 'Value', DropdownValue);
- if DropdownValue == 0
- error('Option does not exist in dropdown list.'); % Error-check
- end
- % Set output handles:
- OutputHandles = handles;
- %=====================================%
- % GUI FUNCTIONS FOR RUNNING ANALYSIS: %
- %=====================================%
- %--- Executes on button press in ButtonStartAnalysis. ---%
- %--------------------------------------------------------%
- function ButtonStartAnalysis_Callback(hObject, eventdata, handles)
- % Check for errors and required settings:
- if isempty(handles.gui.BuilderMat)
- msgbox('ERROR: Builder .mat file has not been loaded yet.', 'Error:')
- return;
- end
- if get(handles.CheckboxMakePLSmat, 'Value') == 1
- if isempty(handles.PLSmat.SessionID)
- msgbox('ERROR: Enter SessionID for PLS run.', 'Error:')
- return;
- end
- if isempty(handles.PLSmat.TimeIndices)
- msgbox('ERROR: Specify AFNI time-indices for PLS.', 'Error:')
- return;
- end
- if ismember(handles.PLSrun.Method, {'BHV', 'MBLOCK', 'NR-BHV', 'NR-MBLOCK'})
- if isempty(handles.PLSmat.BhvFile) && isempty(handles.PLSmat.SeedFile)
- msgbox('ERROR: Select behavior and/or seed .xls files.')
- return;
- end
- if isempty(handles.PLSmat.BhvSeedID)
- msgbox('ERROR: Enter ID for behavior and/or seeds selected.')
- return;
- end
- end
- end
- if get(handles.CheckboxRunPLS, 'Value') == 1
- if isempty(get(handles.TextboxNumPermutations, 'String'))
- msgbox('Error: Number of permutations not specified.', 'Error:');
- return;
- end
- if isempty(get(handles.TextboxNumBootstraps, 'String'))
- msgbox('Error: Number of bootstraps not specified.', 'Error:');
- return;
- end
- if isempty(get(handles.TextboxNumSplits, 'String')) && ...
- get(handles.CheckboxSplitHalfPLS, 'Value') == 1
- msgbox('Error: Number of splits not specified.', 'Error:');
- return;
- end
- if ismember(handles.PLSrun.Method, {'NROT', 'NR-BHV', 'NR-MBLOCK'})
- if isempty(handles.PLSrun.NRContrast) || isempty(handles.PLSrun.NRContrastID)
- msgbox('ERROR: Enter NR Contrast & Contrast ID.')
- return;
- end
- end
- end
- % Ask user to confirm:
- ConfirmRun = questdlg('CONFIRM: Start analysis with current settings?',...
- 'CONFIRM:', 'YES', 'NO', 'NO');
- if strcmp(ConfirmRun, 'NO')
- return;
- end
- % Check for Matlab PCT:
- CheckOpenPCT
- commandwindow;
- % Run timelock and/or frequency analysis:
- if get(handles.CheckboxTimelockAnalysis, 'Value') == 1
- MEGpipeline_TimelockFreq (handles.gui.BuilderMat, 'Timelock')
- end
- if get(handles.CheckboxTimelockGrpAvg, 'Value') == 1
- MEGpipeline_TimelockFreqAvg (handles.gui.BuilderMat, 'Timelock')
- end
- if get(handles.CheckboxFreqAnalysis, 'Value') == 1
- MEGpipeline_TimelockFreq (handles.gui.BuilderMat, 'Freq')
- end
- if get(handles.CheckboxFreqGrpAvg, 'Value') == 1
- MEGpipeline_TimelockFreqAvg (handles.gui.BuilderMat, 'Freq')
- end
- % Run seg, headmodels & leadfields:
- if get(handles.CheckboxSegmentMRI, 'Value') == 1
- MEGpipeline_SegmentMRI(handles.gui.BuilderMat)
- end
- if get(handles.CheckboxHdmLeadfield, 'Value') == 1
- MEGpipeline_HdmLeadfield(handles.gui.BuilderMat)
- end
- % Run source analysis sections:
- if get(handles.CheckboxSourceFilter, 'Value') == 1
- MEGpipeline_SourceFilter_Wrap(handles.gui.BuilderMat)
- end
- if get(handles.CheckboxSourceAnalysis, 'Value') == 1
- MEGpipeline_SourceAnalysis_Wrap(handles.gui.BuilderMat)
- end
- if get(handles.CheckboxMakeSourceNifti, 'Value') == 1
- MEGpipeline_MakeInterpSourceNii_Wrap (handles.gui.BuilderMat)
- MEGpipeline_MakeMRINii_Wrap (handles.gui.BuilderMat, 'PreprocMRI')
- end
- if get(handles.CheckboxMakeSourceAfni, 'Value') == 1
- MEGpipeline_Nifti4DFunc2AFNI_Wrap (handles.gui.BuilderMat, 'Nifti4DSource')
- MEGpipeline_NiftiAnat2AFNI_Wrap (handles.gui.BuilderMat, 'PreprocMRINii')
- end
- % Run normalise source sections:
- if get(handles.CheckboxNormaliseSource, 'Value') == 1
- MEGpipeline_NormaliseSPM_Wrap(handles.gui.BuilderMat)
- end
- if get(handles.CheckboxMakeNormSrcNifti, 'Value') == 1
- MEGpipeline_MakeNormSourceNii_Wrap (handles.gui.BuilderMat)
- MEGpipeline_MakeMRINii_Wrap (handles.gui.BuilderMat, 'NormMRI')
- end
- if get(handles.CheckboxMakeNormSrcAfni, 'Value') == 1
- MEGpipeline_Nifti4DFunc2AFNI_Wrap (handles.gui.BuilderMat, 'Nifti4DNormSource')
- MEGpipeline_NiftiAnat2AFNI_Wrap (handles.gui.BuilderMat, 'NormMRINii')
- end
- % Run group-average normsource sections:
- if get(handles.CheckboxGroupAvgNormSrc, 'Value') == 1
- MEGpipeline_SourceAvg(handles.gui.BuilderMat)
- end
- if get(handles.CheckboxMakeGrpAvgNifti, 'Value') == 1
- MEGpipeline_MakeGrpAvgNii_Wrap(handles.gui.BuilderMat)
- end
- if get(handles.CheckboxMakeGrpAvgAfni, 'Value') == 1
- MEGpipeline_Nifti4DFunc2AFNI_Wrap(handles.gui.BuilderMat, 'Nifti4DGrpAvg')
- end
- % Run PLS sections:
- if get(handles.CheckboxMakePLSmat, 'Value') == 1
- InputPLSmat = handles.PLSmat;
-
- if strcmp(InputPLSmat.MaskType, 'BrainMask')
- if strcmp(InputPLSmat.DataSpecificMask, 'yes')
- InputPLSmat.BrainMaskFile = [];
- InputPLSmat.ROIMaskFile = [];
- else
- InputPLSmat.ROIMaskFile = [];
- end
-
- elseif strcmp(InputPLSmat.MaskType, 'ROIMask')
- InputPLSmat.BrainMaskFile = [];
- end
-
- PLSmatReady = MEGpipeline_MakePLSmat(InputPLSmat)
- InputPLSmat = []; % Free memory
-
- if get(handles.CheckboxRunPLS, 'Value') == 0
- msgbox('Debug: Checking datamat without running PLS. Activating keyboard mode.')
- PLSmatReady
- keyboard;
- end
- end
- if get(handles.CheckboxRunPLS, 'Value') == 1
- MEGpipeline_RunPLS(PLSmatReady, handles.PLSrun)
- end
- %=================================%
- % FUNCTION TO OPEN MODAL WAITBOX: %
- %=================================%
- function WaitBox = StartWaitBox(TextString)
- WaitBox = dialog('Units', 'pixels', 'Position', [500 500 300 40],...
- 'Windowstyle', 'modal', 'NextPlot', 'new', 'Name', 'Please Wait:');
- uicontrol('Parent', WaitBox, 'Units', 'pixels', 'Position', [20 10 250 20],...
- 'Style', 'text', 'String', TextString, 'FontWeight', 'bold');
- movegui(WaitBox, 'center');
- %==============================%
- % GUIDE "CREATEFCN" FUNCTIONS: %
- %==============================%
- % --- Executes during object creation, after setting all properties.
- function TextboxBuilderMat_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function ListboxPLSmatGroupID_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function ListboxPLSmatSubjID_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function ListboxPLSmatCondID_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxBrainMaskFile_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxKeepVoxelThresh_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxROIMaskFile_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxROISize_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function SliderTimeStartPLS_CreateFcn(hObject, eventdata, handles)
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes during object creation, after setting all properties.
- function SliderTimeEndPLS_CreateFcn(hObject, eventdata, handles)
- if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor',[.9 .9 .9]);
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxTimeStartPLS_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxTimeEndPLS_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function ListboxManualTimeSelect_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxBhvSeedID_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxBhvFile_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxSeedFile_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxSeedSize_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxPLSmatSessionID_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function DropdownPLSMethod_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxNumPermutations_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxNumBootstraps_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxNumSplits_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxNRContrast_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function TextboxNRContrastID_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function DropdownMCentType_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function DropdownCorrMode_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function DropdownPermType_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- % --- Executes during object creation, after setting all properties.
- function DropdownBootType_CreateFcn(hObject, eventdata, handles)
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
|